<template>
  <div>
    <h1>院校信息</h1>
    <div>vuex方法user：{{ state.user.num }}</div>
    <div>vuex方法info：{{ state.info.name }}</div>
    <el-button @click="addNum" type="primary">加法</el-button>
    <el-button @click="subNum" type="warning">减法</el-button>
    <el-button @click="rideNum" type="warning">乘法</el-button>
    <el-button @click="changeName" type="primary">改变名字</el-button>
  </div>
</template>

<script setup>
import { computed } from "@vue/runtime-core";
import { useStore, mapState } from "vuex";
const { state, commit, dispatch } = useStore();
let addNum = () => {
  commit("user/addNum"); // 调用user文件里的addNum方法（mutations）
};
let subNum = () => {
  commit("user/subNum", 13); // 调用user文件里的subNum方法（mutations）
};
let rideNum = () => {
  dispatch("user/changNum", 2); // 调用user文件里的changeNum方法（actions）
};
let changeName = () => {
  commit('info/changeName', '我的名字叫做王坤')
}


</script>
<style lang="scss" scoped module></style>
